import request from "@/util/request"

// src/api/CoachApi.js (如果存在此文件)
export async function getCoaches(currentPage = 1, pageSize = 10, searchQuery = '') {
    const res = await request.get('/coach/msg', {
        page: currentPage,
        page_size: pageSize,
        search: searchQuery
    });

    // 处理统一的数据结构
    if (res.data.data && res.data.data.list) {
        return {
            list: res.data.data.list,
            total: res.data.data.total,
            page: res.data.data.page,
            page_size: res.data.data.page_size
        }
    } else {
        // 兼容旧的数据结构
        return {
            list: res.data.data,
            total: res.data.total
        }
    }
}

export async function getCoachDetail(coach_id) {
    const res = await request.get(`/coach/msg/${coach_id}`);
    return res.data.data;
}

export async function bookCoach(appointmentData) {
    const res = await request.post('/appointment/add', appointmentData);
    return res.data.data;
}
